package com.tensquare.friend;

import com.tensquare.friend.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 使用该类配置SpringMVC(拦截器)
 * 将拦截器进行注册和配置
 */
@Configuration
public class WebConfiguration extends WebMvcConfigurationSupport{

    @Autowired
    private JwtInterceptor interceptor;

    /**
     * 添加(注册拦截器)
     * @param registry
     */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor)  //将Jwt拦截器添加
                .addPathPatterns("/**");  //指定拦截路径
    }
}
